package com.huatai.datacenter.controller.datasubject;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.huatai.common.api.R;
import com.huatai.datacenter.entity.subject.SubjectDirectoryEntity;
import com.huatai.datacenter.service.SubjectDirectoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author gusiyi
 * @version 1.0
 * @className SubjectDirectoryController
 * @description 描述：
 * @date 2023/6/6 11:41
 */
@RestController
@Api(value = "主题目录管理",tags = "主题目录管理")
@RequestMapping("/dataSubject/directory")
public class SubjectDirectoryController {

	@Autowired
	private SubjectDirectoryService subjectDirectoryService;

	@RequestMapping("/getList")
	@ApiOperation("获取主题目录清册")
	@ApiOperationSupport(order = 1,includeParameters = {
		"subjectDirectoryEntity.subjectDirectoryName",
		"subjectDirectoryEntity.pageIndex",
		"subjectDirectoryEntity.pageSize",
		"subjectDirectoryEntity.typeContent"
	})
	public R<Page<SubjectDirectoryEntity>> getSubList(@RequestBody SubjectDirectoryEntity subjectDirectoryEntity){
		return R.data(subjectDirectoryService.getSubList(subjectDirectoryEntity),"获取主题目录清册成功");
	}

	@RequestMapping("/saveOne")
	@ApiOperation("创建主题目录")
	@ApiOperationSupport(order = 2,includeParameters = {
		"subjectDirectoryEntity.subjectDirectoryName",
		"subjectDirectoryEntity.subjectDirectoryTypeNum",
		"subjectDirectoryEntity.subjectDirectoryTypeName",
		"subjectDirectoryEntity.dataProvider",
		"subjectDirectoryEntity.phoneNumber"
	})
	public R<SubjectDirectoryEntity> saveSub(@RequestBody SubjectDirectoryEntity subjectDirectoryEntity){
		return R.status(subjectDirectoryService.save(subjectDirectoryEntity));
	}

	@RequestMapping("/updateById")
	@ApiOperation("修改主题目录")
	@ApiOperationSupport(order = 3,includeParameters = {
		"subjectDirectoryEntity.id",
		"subjectDirectoryEntity.subjectDirectoryName",
		"subjectDirectoryEntity.subjectDirectoryTypeNum",
		"subjectDirectoryEntity.subjectDirectoryTypeName",
		"subjectDirectoryEntity.dataProvider",
		"subjectDirectoryEntity.phoneNumber"
	})
	public R<SubjectDirectoryEntity> updateById(@Valid @RequestBody SubjectDirectoryEntity subjectDirectoryEntity){
		subjectDirectoryEntity.setUpdateTime(null);
		subjectDirectoryEntity.setUpdateUserid(null);
		subjectDirectoryEntity.setDeleted(null);
		return R.status(subjectDirectoryService.updateById(subjectDirectoryEntity));
	}

	@RequestMapping("deleteByIds")
	@ApiOperation("删除主题目录")
	@ApiOperationSupport(order = 4,includeParameters = {
		"subjectDirectoryEntityIds.id"
	})
	public R<SubjectDirectoryEntity> deleteByIds(@Valid @RequestBody List<SubjectDirectoryEntity> subjectDirectoryEntityIds){
		return R.status(subjectDirectoryService.deleteByIds(subjectDirectoryEntityIds));
	}

}
